# coding:utf-8
"""
    @project: automated_testing_platform
    @Author：caicaizi
    @file： run_case.py
    @date：2023/5/30 21:42
"""
from webcases.utils.web_testing_utils.base_web_driver import BaseWebDriver


def run_case(case, steps):
    driver = BaseWebDriver(driver_name=case.browser)
    for step in steps:
        name = step.step_name
        order = step.step_order
        by = step.locate_by
        pattern = step.locate_pattern
        value = step.value
        if order == 'open_url':
            driver.open_url(pattern)
        elif order == 'send_keys':
            driver.send_keys(by, pattern, value)
        elif order == 'click_element':
            driver.click_element(by, pattern)
